﻿using System.ComponentModel;
using EDMDesigner.Business.FunctionBase;
using EDMDesigner.Business.Util;

namespace EDMDesigner.Business.SSDL.Function
{
    public class FunctionParameter : INotifyPropertyChanged, INamedElement
    {
        private string _name;
        public string Name
        {
            get { return _name; }
            set 
            {
                _name = value;
                OnPropertyChanged("Name");
            }
        }

        private string _type;
        public string Type
        {
            get { return _type; }
            set 
            {
                _type = value;
                OnPropertyChanged("Type");
            }
        }

        private ParameterMode _mode;
        public ParameterMode Mode
        {
            get { return _mode; }
            set 
            {
                _mode = value;
                OnPropertyChanged("Mode");
            }
        }

        private int? _maxLength;
        public int? MaxLength
        {
            get { return _maxLength; }
            set 
            {
                _maxLength = value;
                OnPropertyChanged("MaxLength");
            }
        }

        private int? _precision;
        public int? Precision
        {
            get { return _precision; }
            set 
            {
                _precision = value;
                OnPropertyChanged("Precision");
            }
        }

        private int? _scale;
        public int? Scale
        {
            get { return _scale; }
            set 
            {
                _scale = value;
                OnPropertyChanged("Scale");
            }
        }

        public string StoreName { get; set; }
        public string StoreSchema { get; set; }
        public string StoreType { get; set; }

        protected virtual void OnPropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }
        public event PropertyChangedEventHandler PropertyChanged;
    }
}
